<template>
    <div class="goeasy-audio-player" @click="playAudio">
        <div class="audio-facade" :style="{width:Math.ceil(duration/1000)*5 + 80 + 'px'}">
            <span class="audio-facade-bg"> </span>
            <span>{{Math.ceil(duration/1000)}}"</span>
        </div>
        <audio ref="audioPlayer"></audio>
    </div>
</template>

<script>
    export default {
        name: "GoEasyAudioPlayer",
        props : ['src', 'duration'],
        data () {
            return {
            }
        },
        methods : {
            playAudio () {
                this.$refs.audioPlayer.src =this.src;
                this.$refs.audioPlayer.currentTime = 0;
                this.$refs.audioPlayer.play();
            }
        }
    }
</script>

<style scoped>
    .goeasy-audio-player{

    }
    .audio-facade{
        min-width: 0.2rem;
        padding: 0.03rem 0.1rem;
        height: 0.26rem;
        line-height: 0.2rem;
        background: #D02129;
        font-size: 0.12rem;
        border-radius: 0.15rem;
        color: #ffffff;
        -webkit-tap-highlight-color:rgba(0,0,0,0);
        display: flex;
    }
    .audio-facade-bg{
        background: url("../assets/images/voice.png") no-repeat center;
        background-size: 18px;
        width: 20px;
    }
</style>